package xl.com.service;

import com.mysql.cj.x.protobuf.MysqlxExpr;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;

// 步骤3：扩展Function Calling
// 步骤4：实现Function Calling处理器
@Service
public class FunctionCallingService {
    @Autowired
    private  BusinessDataService businessDataService;

    // 注册所有业务函数
    private final Map<String, Function<Map<String, String>, String>> FUNCTIONS = Map.of(
            "query_business_data", params ->
                    businessDataService.queryOrderData(
                            params
                    )
    );

    public String handleFunctionCall(String context) {
        return FUNCTIONS.getOrDefault("query_business_data", p -> "未知函数")
                .apply(Map.of("orderNo",context));
    }
}